﻿#pragma once
#include "typedefs.h"
#include <string>
#include "base.h"

#define MATRIX_TRANSPOSED


#ifdef MATRIX_TRANSPOSED
#define MAT_INDEX(x, y) y+x*4
const int g_bMatrixTransposed = GL_FALSE;
#else
#define MAT_INDEX(x, y) x+y*4
const int g_bMatrixTransposed = GL_TRUE;
#endif

class matrix
{
public:
	matrix(void);
	matrix(const matrix &other);
	~matrix(void);
	matrix Transpose() const;
	matrix operator=(const matrix &other);
	matrix operator+(const matrix &other) const;
	matrix operator-(const matrix &other) const;
	matrix operator*(const matrix &other) const;
	vector4 operator*(const vector4 &other) const;
	float *DataPtr();
	const float *DataPtr() const;
	void LoadIdentity();
	void Zero();
	std::string ToString() const;

	static matrix Translation(const vector3 &position);
	static matrix Perspective(double fovX, double fAspect, double zNear, double zFar);
	static matrix CenteredOrthogonal(double width, double heigth, double zNear, double zFar);
	static matrix Orthogonal(double left, double right, double bottom, double top, double zNear, double zFar);
	static matrix Rotation(const vector3 &axis, const float &r);
	static matrix Rotation(const vector3 &rotation);
	static matrix RotationX(const float &r);
	static matrix RotationY(const float &r);
	static matrix RotationZ(const float &r);
	static matrix Scale(const vector3 &scale);

	float m_vars[16];
};